import { userProfilesAPI } from "@/request/api"
export default {
    namespaced: true,
    state: {
        userInfo: {
            nickName: "zhangsan",
            coin: 999,
            headImg: require("../../assets/img/service.848ec511.png")
        },
        cartTotal: 5
    },
    mutations: {
        changeUserInfo(state, payload) {
            state.userInfo = payload.userInfo
            state.cartTotal = payload.cartTotal
        },
        initUserInfo(state) {
            state.userInfo = {
                nickName: "zhangsan",
                coin: 999,
                headImg: require("../../assets/img/service.848ec511.png")
            }
            state.cartTotal = 0
        }
    },
    actions: {
        async asyncchangeUserInfo({ commit }) {
            let user = await userProfilesAPI()
            console.log("user", user);
            commit("changeUserInfo", user.data)
        }
    }
}